<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            background: linear-gradient(to left, rgb(230, 101, 123), rgb(117, 185, 185));
            position: absolute;
        }
    </style>
</head>

<body>
    <div class="box"></div>
    <script>
        var box=document.getElementsByClassName("box")[0];
        box.onclick=function(){
            var num=0;
            var timer=setInterval(function(){
                num++
                box.style.left=`${num}px`
                box.style.top=`${num}px`
            },1)
            setTimeout(function(){
                clearInterval(timer)
            },1000000000);
        }
    </script>
</body>

</html>